import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
//==========element-plus==========
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'
//================================


// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        AutoImport({
            resolvers: [ElementPlusResolver()],
        }),
        Components({
            resolvers: [ElementPlusResolver()],
        }),
    ],
    resolve: {
        alias: {
            "@": path.resolve(__dirname, 'src')
        }
    },
    server:{
        /*配置跨域代理*/
        proxy:{
            // 带选项写法：http://localhost:5173/api/bar -> http://jsonplaceholder.typicode.com/bar
            '/api': {
                /*这里提示不安全，不用管*/
                target: 'http://syt.atguigu.cn',
                changeOrigin: true,
                //路径重写，这里不需要
               // rewrite: (path) => path.replace(/^\/api/, ''),
            }
        }
    }
})
